import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
// import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import enLocale from '@/lang/en' // lang i18n
import zhLocale from '@/lang/zh'
import VueI18n from 'vue-i18n'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

import VideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
Vue.use(VideoPlayer)

import * as filters from '@/components/filters' // 引入工具类 filters是一个对象
// 注册全局的过滤器
Object.keys(filters).forEach(key => {
    // 注册过滤器
    Vue.filter(key, filters[key])
})
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */

if (process.env.NODE_ENV === 'production') {
    const { mockXHR } = require('../mock')
    mockXHR()
}

// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明

Vue.use(ElementUI)
Vue.use(VueI18n)
const messages = {
    en: {
        ...enLocale // 或者用 Object.assign({ message: 'hello' }, enLocale)
    },
    zh: {
        ...zhLocale // 或者用 Object.assign({ message: '你好' }, zhLocale)
    }
}
// Create VueI18n instance with options
const i18n = new VueI18n({
    locale: 'zh', // set locale
    messages // set locale messages
})

Vue.use(ElementUI, {
    i18n: (key, value) => i18n.t(key, value)
})

// new Vue({ i18n }).$mount('#app')
Vue.config.productionTip = false

new Vue({
    el: '#app',
    router,
    store,
    i18n,
    render: h => h(App)
})